package com.skill.shareskill.service;

import android.os.Handler;
import android.os.Message;

import com.skill.shareskill.utils.HttpUtils;

import java.io.IOException;

/**
 * Created by Administrator on 2018/1/30 0030.
 */

public class LoadDataThread extends Thread {
    private Handler handler;
    private String activityJsonPath;
    public LoadDataThread(Handler handler, String activityJsonPath){
        this.handler=handler;
        this.activityJsonPath=activityJsonPath;

    }
    @Override
    public void run() {
        // TODO Auto-generated method stub
        String activityJson = null;
        try {
            activityJson = HttpUtils.getContent(activityJsonPath);
            //发送消息给UI线程更新数据
            Message msg = handler.obtainMessage();
            //将消息设置到msg对象的obj属性中
            msg.obj = activityJson;
            //发送消息
            handler.sendMessage(msg);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
